package com.classeven.downhill.state;

import org.andengine.entity.modifier.FadeInModifier;
import org.andengine.entity.modifier.FadeOutModifier;

import com.classeven.downhill.define.iGameDefines;
import com.classeven.downhill.element.AScene;
import com.classeven.downhill.element.ASprite;
import com.classeven.downhill.engine.GameEngine;

public class State_Logo {

	ASprite logo, logo2;
	GameEngine engine;
	AScene scene;
	
	public static byte lgo;
	
	public State_Logo(GameEngine engine)
	{
		this.engine = engine;
		logo = new ASprite(engine, iGameDefines.SPRITE_LAUNCH, 0);
		logo2 = new ASprite(engine, iGameDefines.SPRITE_LAUNCH, 1);
		scene = new AScene(1);
		engine.SetGameScene(scene);
		
	}
	
	public void init()
	{
		switch (lgo) {
		case 0:
			engine.SceneAttach(scene, logo);
			logo.theSprite().registerEntityModifier(new FadeInModifier(2f));
			break;

		case 1:
			engine.SceneAttach(scene, logo2);
			logo2.theSprite().registerEntityModifier(new FadeInModifier(4f));
			break;
		}
		
	}
	
	public void update()
	{
		switch (lgo) {
		case 0:
			if(System.currentTimeMillis() % 200 == 0)
			{
				engine.SetNextMessageState(engine.NextMessageState());
							
			}
			logo.theSprite().registerEntityModifier(new FadeOutModifier(4f));
		break;
		case 1:
		
			if(System.currentTimeMillis() % 400 == 0)
			{
				engine.SetNextMessageState(engine.NextMessageState());
							
			}
			logo2.theSprite().registerEntityModifier(new FadeOutModifier(6f));
		break;
		
		
		}
	
	}
	
	public void exit()
	{
		switch (lgo)
		{
		case 0:
			logo.DetachSelf();
			engine.SetNextMessageState(engine.NextMessageState());
			lgo++;
		break;
		
		case 1 :
			logo2.DetachSelf();
			engine.SetNextMessageState(engine.NextMessageState());
			engine.SetNextGameState(engine.NextGameState());
			break;
		}
	}
}

